package com.taotao.job.trigger.route;


import com.taotao.job.trigger.route.strategy.ExecutorRouteFirst;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by cestc on 17/3/10.
 */
@Getter
public enum ExecutorRouteStrategyEnum {

    FIRST("", new ExecutorRouteFirst());

    private String name;
    private ExecutorRouter router;

    ExecutorRouteStrategyEnum(String name, ExecutorRouter router) {
        this.name = name;
        this.router = router;
    }

    private static final Map<String, ExecutorRouter> routerMap = new HashMap<>();

    static {
        ExecutorRouteStrategyEnum[] values = ExecutorRouteStrategyEnum.values();
        for (ExecutorRouteStrategyEnum val : values) {
            routerMap.put(val.name, val.router);
        }
    }


    /**
     * 获取路由器
     *
     * @param name
     * @return
     */
    public static ExecutorRouter getRouter(String name) {
        return routerMap.get(name);
    }

}
